package com.tfswue.group.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tfswue.group.entity.Order;
import com.tfswue.group.mapper.OrderMapper;
import com.tfswue.group.service.OrderService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {

    @Override
    public String generateOrderNo() {
        // 生成订单号: 年月日时分秒+6位随机数
        LocalDateTime now = LocalDateTime.now();
        String date = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
        Random random = new Random();
        int randomNum = random.nextInt(900000) + 100000; // 生成6位随机数
        return date + randomNum;
    }

    @Override
    public Order createOrder(Order order) {
        return null;
    }
}